﻿namespace Game
{
    class Intro
    {
        public void Run()
        {
            Font sans34 = new Font("data/Almonte Snow.ttf", 34);
            Image background = new Image("data/lemmings_menu.jpg");
            bool finished = false;

            do
            {
                Hardware.ClearScreen();

                Hardware.DrawHiddenImage(background, 0, 0);

                Hardware.WriteHiddenText("Click",
                    35, 460,
                    0xCC, 0xCC, 0xCC,
                    sans34);
                Hardware.WriteHiddenText("to start",
                    35, 490,
                    0xCC, 0xCC, 0xCC,
                    sans34);

                Hardware.WriteHiddenText("Select",
                   210, 460,
                   0xCC, 0xCC, 0xCC,
                   sans34);
                Hardware.WriteHiddenText("Level",
                    210, 490,
                    0xCC, 0xCC, 0xCC,
                    sans34);

                Hardware.WriteHiddenText("H for",
                    380, 460,
                    0xCC, 0xCC, 0xCC,
                    sans34);
                Hardware.WriteHiddenText("Help",
                    380, 490,
                    0xCC, 0xCC, 0xCC,
                    sans34);
                Hardware.WriteHiddenText("C for",
                    520, 460,
                    0xCC, 0xCC, 0xCC,
                    sans34);
                Hardware.WriteHiddenText("Credits",
                   520, 490,
                   0xCC, 0xCC, 0xCC,
                   sans34);
                Hardware.WriteHiddenText("Q to",
                    690, 460,
                    0xCC, 0xCC, 0xCC,
                    sans34);
                Hardware.WriteHiddenText("Quit",
                    690, 490,
                    0xCC, 0xCC, 0xCC,
                    sans34);
                Hardware.ShowHiddenScreen();

                Hardware.Pause(20);

                if (Hardware.KeyPressed(Hardware.KEY_C))
                {
                    Credits creditsScreen = new Credits();
                    creditsScreen.Run();
                }
                
                if (Hardware.KeyPressed(Hardware.KEY_H))
                {
                    Help helpScreen = new Help();
                    helpScreen.Run();
                }

                if (Hardware.KeyPressed(Hardware.KEY_SPC))
                {
                    Game myGame = new Game();
                    myGame.Run();
                }

                int posXMouse = 0;
                int posYMouse = 0;

                if (Hardware.MouseKeyDown(out posXMouse, out posYMouse))
                {
                    if(posXMouse > 20 &&
                       posXMouse < 160 &&
                       posYMouse > 420 &&
                       posYMouse < 550 )
                    {
                        Game myGame = new Game();
                        myGame.Run();
                    }

                    if (posXMouse > 180 &&
                       posXMouse < 320 &&
                       posYMouse > 420 &&
                       posYMouse < 550)
                    {
                        Level levelScreen = new Level();
                        levelScreen.Run();
                    }

                    if (posXMouse > 340 &&
                       posXMouse < 470 &&
                       posYMouse > 420 &&
                       posYMouse < 550)
                    {
                        Help helpScreen = new Help();
                        helpScreen.Run();
                    }

                    if (posXMouse > 490 &&
                       posXMouse < 620 &&
                       posYMouse > 420 &&
                       posYMouse < 550)
                    {
                        Credits creditsScreen = new Credits();
                        creditsScreen.Run();
                    }

                    if (posXMouse > 640 &&
                       posXMouse < 780 &&
                       posYMouse > 420 &&
                       posYMouse < 550)
                    {
                        finished = true;
                    }
                }
            }
            while (!finished);
        }
    }
}
